package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.GGardener;
import com.ruoyi.system.service.IGGardenerService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.GAttendance;
import com.ruoyi.system.service.IGAttendanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考勤信息管理Controller
 * 
 * @author nb
 * @date 2024-05-09
 */
@RestController
@RequestMapping("/system/attendance")
public class GAttendanceController extends BaseController
{
    @Autowired
    private IGAttendanceService gAttendanceService;

    @Autowired
    private IGGardenerService gGardenerService;

    /**
     * 查询mingz列表
     */

    @GetMapping("/kqxxlist")
    public AjaxResult kqxxlist(GGardener gGardener)
    {
        //查询名字
        List<GGardener> list = gGardenerService.selectGGardenerList(gGardener);
        return success(list);
    }

    /**
     * 查询考勤信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:attendance:list')")
    @GetMapping("/list")
    public TableDataInfo list(GAttendance gAttendance)
    {
        startPage();
        List<GAttendance> list = gAttendanceService.selectGAttendanceList(gAttendance);
        return getDataTable(list);
    }

    /**
     * 导出考勤信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:attendance:export')")
    @Log(title = "考勤信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GAttendance gAttendance)
    {
        List<GAttendance> list = gAttendanceService.selectGAttendanceList(gAttendance);
        ExcelUtil<GAttendance> util = new ExcelUtil<GAttendance>(GAttendance.class);
        util.exportExcel(response, list, "考勤信息管理数据");
    }

    /**
     * 获取考勤信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:attendance:query')")
    @GetMapping(value = "/{aid}")
    public AjaxResult getInfo(@PathVariable("aid") Integer aid)
    {
        return success(gAttendanceService.selectGAttendanceByAid(aid));
    }

    /**
     * 新增考勤信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:attendance:add')")
    @Log(title = "考勤信息管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GAttendance gAttendance)
    {
        return toAjax(gAttendanceService.insertGAttendance(gAttendance));
    }

    /**
     * 修改考勤信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:attendance:edit')")
    @Log(title = "考勤信息管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GAttendance gAttendance)
    {
        return toAjax(gAttendanceService.updateGAttendance(gAttendance));
    }

    /**
     * 删除考勤信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:attendance:remove')")
    @Log(title = "考勤信息管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{aids}")
    public AjaxResult remove(@PathVariable Integer[] aids)
    {
        return toAjax(gAttendanceService.deleteGAttendanceByAids(aids));
    }
}
